import request from '@/utils/request';

export function getCateList() {
    return request({
        url: '/v1/goods/category/queryList',
        method: 'post',
        data: {}
    });
}

export function getSupplierList() {
    return request({
        url: '/v1/supplier/list',
        method: 'post',
        data: {}
    });
}

export function getGoodsList(queryData) {
    return request({
        url: '/v1/goods/list',
        method: 'post',
        data: queryData
    });
}

export function createGoods(queryData) {
    return request({
        url: '/v1/goods/create',
        method: 'post',
        data: queryData
    });
}

export function getUnsaleGoodsList({ pageNum, pageSize, categoryId, supplierId, nameOrCode }) {
    return request({
        url: '/v1/goods/list/noact',
        method: 'post',
        data: {
            categoryId: !!categoryId ? categoryId : undefined,
            supplierId: !!supplierId ? supplierId : undefined,
            nameOrCode: !!nameOrCode ? nameOrCode : undefined,
            pageNum,
            pageSize
        }
    });
}

export function getGoodsDetail(id) {
    return request({
        url: '/v1/goods/detail/' + id,
        method: 'get',
        data: {}
    });
}

export function updateGoods(queryData) {
    return request({
        url: '/v1/goods/update',
        method: 'post',
        data: queryData
    });
}
export function checkGoodName(queryData) {
    return request({
        url: '/v1/goods/name/exist',
        method: 'get',
        params: queryData
    });
}
